﻿using System.Data.Odbc;
using System.Data.OleDb;
 
namespace Lemonc.Data
{
    public class DBAccessFactory
    {
        public static IDBAccess GetDBAccess(DBAccessType type, string connectionString)
        {
            IDBAccess result = null;
            switch (type)
            {
                case DBAccessType.Sql:
                    result = new DBAccess<System.Data.SqlClient.SqlConnection, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlParameter, System.Data.SqlClient.SqlDataAdapter, System.Data.SqlClient.SqlCommandBuilder>(DBAccessType.Sql, connectionString);
                    break;
                case DBAccessType.Odbc:
                    result = new DBAccess<OdbcConnection, OdbcCommand, OdbcParameter, OdbcDataAdapter, OdbcCommandBuilder>(DBAccessType.Odbc, connectionString);
                    break;
                case DBAccessType.OleDb:
                    result = new DBAccess<OleDbConnection, OleDbCommand, OleDbParameter, OleDbDataAdapter, OleDbCommandBuilder>(DBAccessType.OleDb, connectionString);
                    break;
                case DBAccessType.Oracle:
                    result = new DBAccess<System.Data.OracleClient.OracleConnection, System.Data.OracleClient.OracleCommand, System.Data.OracleClient.OracleParameter, System.Data.OracleClient.OracleDataAdapter, System.Data.OracleClient.OracleCommandBuilder>(DBAccessType.Oracle, connectionString);
                    break;
                case DBAccessType.OracleLight:
                    result = new DBAccess<Oracle.ManagedDataAccess.Client.OracleConnection, Oracle.ManagedDataAccess.Client.OracleCommand, Oracle.ManagedDataAccess.Client.OracleParameter, Oracle.ManagedDataAccess.Client.OracleDataAdapter, Oracle.ManagedDataAccess.Client.OracleCommandBuilder>(DBAccessType.OracleLight, connectionString);
                    break;
            }
            return result;
        }
    }
}
